package cn.zy.chapter2.controller;

import cn.zy.chapter2.model.Customer;
import cn.zy.chapter2.service.CustomerService;
import cn.zy.framework.annotation.Action;
import cn.zy.framework.annotation.Controller;
import cn.zy.framework.annotation.Inject;
import cn.zy.framework.bean.Param;
import cn.zy.framework.bean.View;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * @Author: Administrator
 * @Description:
 * @Date: Created in 21:55 2021/9/9
 * @Modified By:
 * @version: 1.0
 */
@Controller
public class CustomerServlet {

	private static final Logger LOG = LoggerFactory.getLogger(cn.zy.chapter2.controller.CustomerServlet.class);
	@Inject
	private CustomerService customerService;

	/**
	 * 客户列表
	 * @param param
	 * @return
	 */
	@Action("get:/customer")
	public View index(Param param){
		List<Customer> customerList= customerService.getCustomerList();
		return new View("customer.jsp").addModel("customerList", customerList);
	}

	/**
	 * 显示客户信息
	 * @param param
	 * @return
	 */
	@Action("get:/customer_show")
	public View show(Param param){
		long id = param.getLong("id");
		Customer customer = customerService.getCustomer(id);
		return new View("customer_show.jsp").addModel("customer", customer);
	}


}
